package com.beaven.imclient.base;

import android.content.Context;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.inputmethod.InputMethodManager;

/**
 * author: Beaven
 * time: 2017/5/22 9:57
 */

public abstract class BaseActivity extends AppCompatActivity {

  @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initBefore();
    setContentView(getLayoutId());
    initWidget();
    initData();
  }

  protected void initBefore() {
  }

  public abstract int getLayoutId();

  protected void initWidget() {
  }

  protected void initData() {
  }

  public void hideSoftInput(IBinder token) {
    if (token != null) {
      InputMethodManager inputMethodManager =
          (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      inputMethodManager.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS);
    }
  }
}
